﻿@model Lead2012.Business.FieldGroupInfo
@{
    var group = Model;
    var index = ViewData["GroupIndex"].ToString().ToLower();
}

<tr class="line new">
    <td>
        <span class="w">
            @if (index == "first")
            {
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_down" title="Down"></a>
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_up_off" title="Up"></a>
            }
            else if (index == "last")
            {
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_down_off" title="Down"></a>
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_up" title="Up"></a>
            }
            else if (index == "one")
            {
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_down_off" title="Down"></a>
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_up_off" title="Up"></a>
            }
            else
            {
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_down" title="Down"></a>
                <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sortorder arrow_up" title="Up"></a>
            }
        </span>
    </td>
	<td>
        <span class="w">
            <span class="icon_group"></span>
            <span>@group.Title</span>
            <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="sections">Thêm mới vùng</a> |
            <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="fields">Thêm mới trường</a>
        </span>
    </td>
	<td class="rightalign"><span class="w">-</span></td>
    <td class="rightalign"><span class="w">-</span></td>
    <td class="rightalign"><span class="w">-</span></td>
	<td class="rightalign"><span class="w">-</span></td>
	<td class="rightalign"><span class="w">-</span></td>
	<td class="datetime last centeralign">
        <span class="w">
            <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="edit" title="@group.Title">Sửa</a> |
            <a href="javascript:void(0)" rel='@string.Format("group{0}", group.Id)' class="delete" title="@group.Title">Xóa</a>
        </span>
    </td>
</tr>
                
@if (group.Fields != null && group.Fields.Count > 0)
{
    int i = 0;
    foreach (var field in group.Fields)
    {
        i++;
        <tr class="line">
            <td>
                <span class="w">
                    @if (i == 1)
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_down" title="Down"></a>
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_up_off" title="Up"></a>
                    }
                    else if (i == group.Fields.Count)
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_down_off" title="Down"></a>
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_up" title="Up"></a>
                    }
                    else
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_down" title="Down"></a>
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="sortorder arrow_up" title="Up"></a>
                    }
                </span>
            </td>
		    <td>
                <span class="w">
                    <span class="icon_field"></span>
                    <span>@field.Title</span>
                    @if (field.TypeId == 64 || field.TypeId == 1024)
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="items">Sửa các mục</a>
                    }
                </span>
            </td>
		    <td class="centeralign">
                <span class="w">@field.TypeName</span>
            </td>
            <td class="centeralign">
                <span class="w">
                    @if(field.LeadFormTypes!=null && field.LeadFormTypes.Count>0)
                    {
                        @field.LeadFormTypes[0].Name
                    }
                </span>
            </td>
		    <td class="centeralign">
                    @if (field.Required)
                    {
                        <span class="w">Bắt buộc</span>
                    }
                    else
                    {
                        <span class="w">Tùy chọn</span>
                    }
                                
            </td>
		    <td class="centeralign">
                @if (field.Visibility == "READONLY")
                {
                    <span class="w"><a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="visibility">Chỉ đọc</a></span>
                }
                else if (field.Visibility == "NO")
                {
                    <span class="w"><a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="visibility">Không</a></span>
                }
                else
                {
                    <span class="w"><a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="visibility">Có</a></span>
                }
            </td>
		    <td class="centeralign">
                <span class="w">
                    @if (field.Printable)
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="print">Có</a>
                    }
                    else
                    {
                        <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="print">Không</a>
                    }
                                    
                </span>
            </td>
		    <td class="datetime last centeralign">
                <span class="w">
                    <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="edit">Sửa</a> |
                    <a href="javascript:void(0)" rel='@string.Format("field{0}", field.Id)' class="delete" title="@field.Title">Xóa</a>
                </span>
            </td>
	    </tr>
    }
}
